package source.model;

import source.model.type.AreaEffectType;
import source.model.type.AreaEffect_Teleport_Type;
import source.view.MainScreen;

public class AreaEffect_Teleport extends AreaEffect {
	private AreaEffect_Teleport_Type AETT;
	private Position teleportToLocation;
	
	public AreaEffect_Teleport(AreaEffect_Teleport_Type AETT, Position teleportToLocation){
		super(AreaEffectType.TELEPORT);
		this.AETT = AETT;
		this.teleportToLocation = teleportToLocation;
	}

	public boolean doEffect(Unit u){
		//MainScreen.writeToConsole("AreaEffect_Teleport call failed");
		return false;
	}

	public boolean doEffect(DataHandler dh, Unit u){
		MainScreen.writeToConsole(u.getType() + " is teleporting...");
		
		//Check to make sure the position can be moved on to 
		if( !teleportToLocation.isValid() ){
			//MainScreen.writeToConsole("Target position is invalid");
			return false;
		}

		if( !dh.positionCommand( u.objectID(), teleportToLocation)){
			//MainScreen.writeToConsole("Teleport: DataHandler.positionCommand failed");
			return false;
		}

		dh.returnObject(u);
		return true;
	}
}	
